package cn.zhf.shop.controller;

import cn.zhf.shop.entity.CreditApply;
import cn.zhf.shop.entity.CreditBank;
import cn.zhf.shop.entity.Message;
import cn.zhf.shop.service.CreditBankService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Api(tags = "信用卡银行模块")
@RequestMapping("/api/creditBank")
public class CreditBankController {

    @Resource
    private CreditBankService creditBankService;

    @GetMapping("/all")
    @ApiOperation(value = "获取所有信用卡银行")
    public Message<List<CreditBank>> getAll(){
        return creditBankService.selectAll();
    }

    @GetMapping("/one")
    @ApiOperation(value = "根据id获得信用卡银行")
    public Message<CreditBank> getById(Integer creditBankId){
        return creditBankService.selectByPrimaryKey(creditBankId);
    }

    @PostMapping("/")
    @ApiOperation(value = "新增信用卡银行")
    public Message<?> insert(CreditBank c){

        return creditBankService.insert(c);
    }

    @DeleteMapping("/")
    @ApiOperation(value = "删除信用卡银行")
    public Message<?> delete(Integer creditBankId){
        return creditBankService.deleteByPrimaryKey(creditBankId);
    }

    @PutMapping("/")
    @ApiOperation(value = "修改信用卡银行")
    public Message update(CreditBank creditBank){
        return creditBankService.updateByPrimaryKeySelective(creditBank);
    }
}
